// request对象其实是axios实例
import { Key } from 'react'
import { request } from '@/utils/http'

// 引入ts类型
import {
  IhospitalSetRes,
  IhospitalAdd,
  IhospitalSet,
} from './model/hospitalSetTypes'

// 获取医院设置表格数据
export const reqHospitalSets = (
  page: number,
  limit: number,
  hosname?: string,
  hoscode?: string
) => {
  console.log(hosname, hoscode)

  return request.get<any, IhospitalSetRes>(
    `/admin/hosp/hospitalSet/${page}/${limit}`,
    {
      params: {
        hosname,
        hoscode,
      },
    }
  )
}

// 添加医院设置
export const reqAddHospitalSet = (params: IhospitalAdd) => {
  return request.post<any, null>(`/admin/hosp/hospitalSet/save`, params)
}

// 获取一条医院设置数据的函数
export const reqGetHospitalSet = (id: string) => {
  return request.get<any, IhospitalSet>(`/admin/hosp/hospitalSet/get/${id}`)
}

// 修改医院设置的函数
export const reqEditHospitalSet = (params: IhospitalAdd) => {
  return request.put<any, null>(`/admin/hosp/hospitalSet/update`, params)
}
// 删除一条医院设置
export const reqDelHospitalSet = (id: string) => {
  return request.delete<any, null>(`/admin/hosp/hospitalSet/remove/${id}`)
}
// 批量删除医院设置
export const reqBatchDelHospitalSet = (ids: Key[]) => {
  return request.delete<any, null>(`/admin/hosp/hospitalSet/batchRemove`, {
    data: ids,
  })
}
